package test;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import Beans.Artigiano;
import businessLogic.GestioneArtigianiMySQL;
import connessioni.MyConnection;
import db_operations.GestioneArtigiani;

public class ModificaArtigiano_Test1 {

	public static void main(String args[]) throws Exception {
		
		try {
			
Connection con = MyConnection.getConnection();
			
			Statement st = con.createStatement();
			
			
			ResultSet n = st.executeQuery("SELECT MAX(ID) FROM artigiani");
			if(!n.next())
				throw new Exception("Nessun artigiano nel DB");
			
			int id = n.getInt(1);
			
			GestioneArtigiani ga = new GestioneArtigianiMySQL();
			Artigiano a = ga.getArtigiano(id);
			
			a.setNome("modificatooo");
			a.setTelefono(new String[0]); //nessuno
			a.setFax(new String[0]);
			
			ga.modificaArtigiano(a);
			
		}
		catch(SQLException e) {
			e.printStackTrace();
		}
		catch(ClassNotFoundException ex) {
			ex.printStackTrace();
		}
		
	}
}
